package com.cloudsigns.factorymanager2.engineering.presenter;

import com.cloudsigns.factorymanager2.engineering.IView.IPublicationCommentFormanagerView;
import com.cloudsigns.factorymanager2.engineering.model.IPublicationCommentFormanagerModel;
import com.cloudsigns.factorymanager2.engineering.model.PublicationCommentFormanagerModel;

/**
 * Created by tony on 2018/6/18.
 */

public class PublicationCommentFormanagerPresenter {
    private IPublicationCommentFormanagerView view;
    private IPublicationCommentFormanagerModel model;
    private android.os.Handler mHandler = new android.os.Handler();

    public PublicationCommentFormanagerPresenter(IPublicationCommentFormanagerView view) {
        this.view = view;
        this.model = new PublicationCommentFormanagerModel();
    }

    public void publicationCommentFormanager() {


        model.publicationCommentFormanager(view.getOrderId(),view.getComment(), new PublicationCommentFormanagerModel.OnPublicationCommentFormanagerModelListener() {
            @Override
            public void publicationCommentFormanagerModelSunccessed() {
                //需要在UI线程执行
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.publicationCommentFormanagerSuccess();
                        view.hideLoading();
                    }
                });
            }

            @Override
            public void publicationCommentFormanagerModelFailed(final String desc) {
                mHandler.post(new Runnable() {
                    @Override
                    public void run() {
                        view.publicationCommentFormanagerFailed(desc);
                        view.hideLoading();
                    }
                });
            }


        });
    }
}
